{{include file="public/header" /}}

<!-- right content start  -->
<div class="content-right">
	<div class="content">
        <!-- operation start -->
        <div class="am-g">
            <button class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus tree-submit-add" data-am-modal="{target: '#data-save-win'}"> 新增</button>
        </div>
        <!-- operation end -->

        <!-- save win start -->
        <div class="am-popup am-radius" id="data-save-win">
			<div class="am-popup-inner">
				<div class="am-popup-hd">
					<h4 class="am-popup-title" data-add-title="分类添加" data-edit-title="分类编辑">分类添加</h4>
					<span data-am-modal-close class="am-close">&times;</span>
				</div>
				<div class="am-popup-bd">
					<!-- form start -->
					<form class="am-form form-validation admin-save" action="{{:MyUrl('admin/goodscategory/save')}}" method="POST" request-type="ajax-fun" request-value="TreeFormSaveBack">
						<div class="am-form-group">
							<label class="block">父级</label>
							<select name="pid" class="am-radius chosen-select forth-selection-form-category" data-placeholder="可选择..." data-validation-message="请选择商品分类">
	                            <option value="0">可选择...</option>
	                            {{if !empty($goods_category_list)}}
	                                {{foreach $goods_category_list as $v}}
	                                    <option value="{{$v.id}}">一级 - {{$v.name}}</option>
	                                    {{if !empty($v['items'])}}
	                                        {{foreach $v.items as $vs}}
	                                            <option style="padding-left: 30px;" value="{{$vs.id}}">二级 - {{$vs.name}}</option>
	                                        {{/foreach}}
	                                    {{/if}}
	                                {{/foreach}}
	                            {{/if}}
	                        </select>
	                    </div>

						<div class="am-form-group am-form-file">
							<label class="block">icon图标</label>
							<ul class="plug-file-upload-view goods-category-icon-images-view" data-form-name="icon" data-max-number="1" data-dialog-type="images">
								<li>
									<input type="hidden" name="icon" value="" />
									<img src="{{$attachment_host}}/static/admin/default/images/default-images.jpg" />
									<i>×</i>
								</li>
							</ul>
							<div class="plug-file-upload-submit" data-view-tag="ul.goods-category-icon-images-view">+上传图片</div>
						</div>
						<div class="am-form-group am-form-file">
							<label class="block">大图片<span class="am-form-group-label-tips">建议大小360x360像素</span></label>
							<ul class="plug-file-upload-view goods-category-big_images-images-view" data-form-name="big_images" data-max-number="1" data-dialog-type="images">
								<li>
									<input type="hidden" name="big_images" value="" />
									<img src="{{$attachment_host}}/static/admin/default/images/default-images.jpg" />
									<i>×</i>
								</li>
							</ul>
							<div class="plug-file-upload-submit" data-view-tag="ul.goods-category-big_images-images-view">+上传图片</div>
						</div>
						<div class="am-form-group">
							<label>背景色</label>
							<input type="hidden" name="bg_color" value="" />
							<button class="am-btn am-btn-default am-btn-xs colorpicker-submit bg-color-tag am-btn-block bk-cr-white t-r" type="button" data-input-tag="button.bg-color-tag" data-color-tag="input[name='bg_color']" data-color-style="background-color">
								<img src="{{$attachment_host}}/static/common/images/colorpicker.png" />
							</button>
						</div>
						<div class="am-form-group">
							<label>名称</label>
							<input type="text" placeholder="名称" name="name" minlength="2" maxlength="16" data-validation-message="名称格式 2~16 个字符" class="am-radius" required />
						</div>
						<div class="am-form-group">
							<label>副名称</label>
							<input type="text" placeholder="副名称" name="vice_name" minlength="0" maxlength="60" data-validation-message="副名称最大60个字符" class="am-radius" />
						</div>
						<div class="am-form-group">
							<label>描述</label>
							<textarea rows="5" name="describe" maxlength="200" class="am-radius" placeholder="描述" data-validation-message="描述最大200个字符"></textarea>
						</div>
						<div class="am-form-group">
						    <label>首页推荐</label>
						    <div>
						        {{foreach $common_is_text_list as $v}}
						            <label class="am-radio-inline am-margin-right-sm">
						                <input type="radio" name="is_home_recommended" value="{{$v.id}}" data-am-ucheck /> {{$v.name}}
						            </label>
						        {{/foreach}}
						    </div>
						</div>
						<div class="am-form-group">
							<label>顺序</label>
							<input type="number" placeholder="顺序" name="sort" min="0" max="255" data-validation-message="顺序 0~255 之间的数值" class="am-radius" value="0" required />
						</div>
						{{include file="lib/enable" /}}
						<div class="am-alert am-alert-secondary">
							{{include file="lib/seo" /}}
						</div>
						<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-horizontal-0">
							<input type="hidden" name="id" />
							<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
						</div>
					</form>
					<!-- form end -->
				</div>
			</div>
		</div>
		<!-- save win end -->

        <!-- list start -->
		<div id="tree" class="am-margin-top-sm" data-additional='[{"field":"bg_color", "value":"", "type":"input"}, {"field":"bg_color", "value":"", "type":"css", "tag":"button.colorpicker-submit", "style":"background-color"}, {"field":"icon", "value":"", "type":"input"}, {"field":"icon", "value":"{{$attachment_host}}/static/admin/default/images/default-images.jpg", "type":"attr", "tag":"ul.goods-category-icon-images-view li img", "style":"src"}, {"field":"big_images", "value":"", "type":"input"}, {"field":"big_images", "value":"{{$attachment_host}}/static/admin/default/images/default-images.jpg", "type":"attr", "tag":"ul.goods-category-big_images-images-view li img", "style":"src"}]' data-node-url="{{:MyUrl('admin/goodscategory/getnodeson')}}" data-del-url="{{:MyUrl('admin/goodscategory/delete')}}" data-popup-tag="#data-save-win" data-rank="3">
			{{include file="public/loading" /}}
		</div>
		<!-- list end -->
	</div>
</div>
<!-- right content end -->
		
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

<script type="text/javascript">
	// 初始化
	Tree(0, $('#tree').data('node-url'), 0, 1, 1);

	// 回调处理
	function TreeFormSaveBack(e)
	{
		TreeFormSaveBackHandle(e);
	}
</script>